﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("BC")]
namespace BE.DataFramework
{
    public class DataTransactionsBE
    {
        public int? iDataTransactionId { get; set; }
        public string sName { get; set; }
        public string sGUID { get; set; }
        public int? iConnectionId { get; set; }
        public string sProcedureName { get; set; }

        public DataTransactionsBE Create()
        {
            try
            {
                DataTransactionsBE result = new DataTransactionsBE();
                using (DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE> datos = new DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE>())
                {
                    result = datos.Create(
                        this.sName,
                        (int)this.iConnectionId,
                        this.sProcedureName);
                }
                return result;
            }
            catch (Exception ex)
            {
                throw new Exception("DataTransactionsBE - Create - ", ex);
            }
        }
        public DataTransactionsBE Update()
        {
            try
            {
                DataTransactionsBE result = new DataTransactionsBE();
                using (DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE> datos = new DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE>())
                {
                    result = datos.Update(
                        (int)this.iDataTransactionId,
                         this.sName,
                        this.sGUID,
                        (int)this.iConnectionId,
                        this.sProcedureName);
                }
                return result;
            }
            catch (Exception ex)
            {
                throw new Exception("DataTransactionsBE - Create - ", ex);
            }
        }
        public int Delete()
        {
            try
            {
                int result = 0;

                using(DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE> datos = new DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE>())
                {
                    result = datos.Delete((int)this.iDataTransactionId);
                }
                return result;
            }
            catch (Exception ex)
            {
                throw new Exception("DataTransactionsBE - Delete - ",ex);
            }
        }
        public List<DataTransactionsBE> Select()
        {
            try
            {
             List<DataTransactionsBE> result = new List<DataTransactionsBE>();

                using(DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE> datos = new DAL.DataFramework.DataTransactionsDAL<DataTransactionsBE>())
                {
                    result = datos.Select(
                        (int)this.iDataTransactionId,
                        this.sName,
                        this.sGUID,
                        (int)this.iConnectionId,
                        this.sProcedureName);
                }
                return result;
            }
            catch (Exception ex)
            {
                throw new Exception("DataTransactionsBE - Select - ",ex);
            }
        }
        public override string ToString()
        {
            return this.sName;
        }
    }
}
